import subprocess

# 定义 Wireshark 可执行文件路径和过滤规则
wireshark_path = "D:\\Software-dev\\Wireshark\\wireshark.exe"  # 根据实际情况修改路径
filter_rule = "tcp port 9090"

# 启动 Wireshark 并设置过滤规则
try:
    subprocess.Popen([wireshark_path, "-f", filter_rule])
    print("Wireshark 已启动并设置过滤规则。")
except FileNotFoundError:
    print("未找到 Wireshark 可执行文件，请检查路径。")
except Exception as e:
    print(f"启动 Wireshark 时出现错误: {e}")